package com.qiaofang.dataprocessing.stub.bean.response;

import com.qiaofang.common.util.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author: youqing.yang
 * @Create: 2020/12/15 15:55
 * @Description:
 **/
@Data
@ApiModel("房源委托列表")
public class PropertyEntrustDTO {

    @ApiModelProperty("主键")
    private Long propertyEntrustId;

    @ApiModelProperty("委托类型")
    private String tradeType;

    @ApiModelProperty("部门名称")
    private String deptName;

    @ApiModelProperty("经纪人姓名")
    private String employeeName;

    @ApiModelProperty("受理人部门id")
    private String acceptDeptId;

    @ApiModelProperty("受理人部门名称")
    private String acceptDeptName;

    @ApiModelProperty("受理人id")
    private String acceptEmployeeId;

    @ApiModelProperty("受理人姓名")
    private String acceptEmployeeName;

    @ApiModelProperty("小区名称")
    private String estateName;

    @ApiModelProperty("栋座号")
    private String buildingName;

    @ApiModelProperty("单元")
    private String unitNo;

    @ApiModelProperty("房号")
    private String roomNo;

    @ApiModelProperty("租金/售价")
    private BigDecimal price;

    @ApiModelProperty("联系人id")
    private String contactId;

    @ApiModelProperty("联系人姓名")
    private String contactName;

    @ApiModelProperty("联系人手机号")
    private String contactPhone;

    @ApiModelProperty("联系人手机号 XXX****XXXX")
    private String contactPhoneEncrypt;

    @ApiModelProperty("委托时间")
    private Date delegateTime;

    @ApiModelProperty("委托时间 yyyy-MM-dd HH:mm:ss")
    private String delegateDate;

    @ApiModelProperty("委托时间 yyyy/MM/dd")
    private String delegateDate1;

    @ApiModelProperty("状态")
    private String entrustStatus;

    @ApiModelProperty("状态")
    private String statusValue;

    @ApiModelProperty("building")
    private String buildingValue;

    @ApiModelProperty("经纪人手机号")
    private String employeePhone;

    @ApiModelProperty("经纪人头像")
    private String employeePhoto;

    public String getBuildingValue() {
        StringBuffer sb = new StringBuffer();
        if(StringUtils.isNotBlank(buildingName)) {
            sb.append(buildingName);
            sb.append("栋");
        }
        if(StringUtils.isNotBlank(unitNo)) {
            sb.append("-");
            sb.append(unitNo);
            sb.append("单元");
        }
        if(StringUtils.isNotBlank(roomNo)) {
            sb.append("-");
            sb.append(roomNo);
            sb.append("号");
        }
        return sb.toString();
    }

    public String getStatusValue() {
        String str = entrustStatus.trim();
        if("0".equals(str)) {
            statusValue = "受理中";
        } else if("1".equals(str)) {
            statusValue = "已受理";
        }
        return statusValue;
    }

    public String getDelegateDate1() {
        if(delegateTime == null) {
            return null;
        }
        delegateDate1 = DateUtil.convertDateToString(delegateTime, "yyyy/MM/dd");
        return delegateDate1;
    }

    public String getDelegateDate() {
        if(delegateTime == null) {
            return null;
        }
        delegateDate = DateUtil.convertDateToString(delegateTime, "yyyy-MM-dd HH:mm:ss");
        return delegateDate;
    }

    public String getContactPhoneEncrypt() {
        if(StringUtils.isBlank(contactPhone)) {
            return null;
        }
        if("1".equals(entrustStatus)) {
            return contactPhone;
        }
        String str = contactPhone.substring(3, 7);
        contactPhoneEncrypt = contactPhone.replace(str, "****");
        return contactPhoneEncrypt;
    }
}
